package com.github.io.controller;

import com.github.io.annotation.Api;
import com.github.io.annotation.ApiOperateNote;
import com.github.io.entity.Menu;
import com.github.io.utils.TreeUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2022/7/28 14:15
 * Description:
 */

@RestController
//@Controller
@Api(value = "菜单控制器")
@RequestMapping("menu")
public class MenuController {
    public static List<Menu> data = new ArrayList<>();

    static {
        data.add(new Menu("1", "0", "/abc"));
        data.add(new Menu("2", "1", "/aaa"));
        data.add(new Menu("3", "1", "/bbb"));
        data.add(new Menu("4", "2", "/ccc"));
        data.add(new Menu("5", "0", "/ddd"));
        data.add(new Menu("6", "5", "/eee"));
        data.add(new Menu("7", "6", "/fff"));
        data.add(new Menu("8", "6", "/ggg"));
    }


    
    @ApiOperateNote(value = "测试树形构造", note = "测试树形构造")
    @GetMapping
    public Object getTreeData(String param1, String param2) {
        
        return TreeUtil.listToTree(data);
    }


    @GetMapping("/index")
    public Object index() {
        return "index";
    }
}
